import { Component, Injector } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { DirectoryItem, FileUploadServiceProxy } from '@shared/service-proxies/service-proxies';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { merge as _merge } from 'lodash-es';
import { finalize } from 'rxjs/operators';

@Component({
    templateUrl: './select-directory-modal.component.html'
})
export class SelectDirectoryModalComponent extends AppComponentBase {

    callback: {(item:string):void};

    saving: boolean = false;

    selectedId: string = "";

    data:DirectoryItem[] = [];


    constructor(
        injector: Injector,
        public bsModalRef: BsModalRef
    ) {
        super(injector);
    }

    close(): void {
        this.bsModalRef.hide();
    }

    shown(data: DirectoryItem[]): void {
        this.data = data;
    }

    save() {
        this.callback && this.callback(this.selectedId);
        this.close();
    }
}
